<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="/common/common.jspf" %>

    <%--下拉搜索框除了依赖下面两个以外还依赖了bootstrap的相关组件以及jquery.js，
    jquery.js和lyGrid.js会有冲突，注意位置    jquery.js放在lyGrid.js上面--%>
    <link rel="stylesheet" href="${ctx}/js/date/bootstrap_select.min.css">
    <script src="${ctx}/js/date/bootstrap_select.min.js"></script>

    <script type="text/javascript" src="${ctx}/js/system/user/add.js">
    </script>




    <style type="text/css">
        .col-sm-3 {
            width: 15%;
            float: left;
        }

        .col-sm-9 {
            width: 35%;
            float: left;
        }
        label[class^="btn btn-default"]{
            margin-top: -4px;
        }
    </style>
</head>
<body>
<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
<form id="form" name="form" class="form-horizontal" method="post"
      action="${ctx}/devicemaintain/maintain_addEntity.shtml">
    <section class="panel panel-default">
        <div class="panel-body">
            <div class="form-group">
                <label class="col-sm-3 control-label">设备维修编号</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control " name="deviceMaintainFormMap.devicemaintaincode" id="devicemaintaincode" value="自动生成" >
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">设备名称</label>
                    <div class="col-sm-9">
                        <select data-live-search="true" class="form-control selectpicker show-tick" name="deviceMaintainFormMap.deviceFaultId" id="deviceFaultId" >
                            <option value="0">--请选择--</option>
                            <c:forEach items="${device}" var="device">
                                <option value="${device.deviceCode}">${device.deviceName}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label" disabled="disabled">设备位置</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control checkName" name="deviceMaintainFormMap.deviceMaintainLocation" id="deviceMaintainLocation">
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">设备型号</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" readonly = readonly
                               placeholder="" name="deviceMaintainFormMap.deviceMaintainType" id="deviceMaintainType">
                    </div>
                </div>
            </div>

            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">报修人</label>
                <div class="col-sm-9">
                    <%--<input type="text" class="form-control"--%>
                           <%--name="deviceMaintainFormMap.deviceMaintainEmp" id="deviceMaintainEmp">--%>
                    <select class="form-control selectpicker show-tick" data-live-search="true" name="deviceMaintainFormMap.deviceMaintainEmp" id="deviceMaintainEmp" >
                        <option value="0">--请选择--</option>
                        <c:forEach items="${emp}" var="emps">
                            <option value="${emps.empId}">${emps.empName}</option>
                        </c:forEach>
                    </select>


                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control "
                               placeholder="请输入备注" name="deviceMaintainFormMap.note" id="note">
                    </div>
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">故障现象</label>
                <div class="col-sm-9">
                     <textarea name="deviceMaintainFormMap.deviceMaintainCause" id="deviceMaintainCause" style="width: 628px; height: 130px;"></textarea>
                </div>
            </div>


        </div>
        <footer class="panel-footer text-right bg-light lter">
            <button type="submit" class="btn btn-success btn-s-xs">提交</button>
        </footer>
    </section>
</form>

<!-- jquery -->
<%--<script src="http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>--%>
<!-- bootstrap -->
<%--<link href="http://cdn.staticfile.org/twitter-bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">--%>
<%--<script src="http://cdn.staticfile.org/twitter-bootstrap/3.3.1/js/bootstrap.min.js" type="text/javascript"></script>--%>
<!-- bootstrap-select -->
<%--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">--%>
<%--<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>--%>


<script type="text/javascript">

    // $(function() {
    //
    // });

    $(document).ready(function(){
        $('select').selectpicker();

        // $('select').selectpicker('refresh');
        // //render方法强制重新渲染引导程序 - 选择ui,如果当您编程时更改任何相关值而影响元素布局，这将非常有用。
        // $('select').selectpicker('render');

        var myDate = getNowFormatDate();
        $("#devicemaintaincode").val("WX"+ myDate + getRandomInt(100,1000));
    });

    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        //OF2022-02-12 13:52:30
        var currentdate = year + seperator1 + month + seperator1 + strDate
            + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
        currentdate= currentdate.replaceAll("-","");
        currentdate= currentdate.replaceAll(":","");
        return currentdate;
    }

    function getRandomInt(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min)) + min; //不含最大值，含最小值
    }


    $("#deviceFaultId").change(function(e){
        var options = $("#deviceFaultId option:selected");//获取选中数据
        console.log("change..")
        $.ajax({
            url: rootPath + "/devicemaintain/getType.shtml",
            data: {id: options.val()},
            type: "GET",
            dataType: "json",
            success: function(data) {
                d = data.replace("\"","").replace("\"","");
                $("#deviceMaintainType").val(d)
            }
        });

    })
</script>
</body>
</html>